import React, { useReducer } from 'react'

export default function App() {
  const initState = {
    count: 0,
    test: '嘿嘿嘿',
  }
  function reducer(state, action) {
    switch (action.type) {
      case 'inc':
        return {
          ...state,
          count: state.count + 1,
        }
    }
  }
 const [state, dispatch] =  useReducer(reducer, initState)
  return <div>
    <p>{state.count}</p>
    <p>{state.msg}</p>
    <button onClick={()=>{
      dispatch({type: 'inc'})
    }}>按钮</button>
  </div>
}
